<!--添加修改角色信息-->
<template>
    <a-modal v-model="showAddTable" :mask-closable="false" :closable="true" :width="900"
             title='实验室审批'
             :maskClosable="false"
             :destroyOnClose="true" @cancel="cancelApply">
        <a-form :form="form" @keydown.native.enter.prevent="saveApprove" class="modelSearch" required>
          <a-form-item label="审批意见：" prop="state" ref="state" v-bind="formStyle">
            <a-radio-group name="radioGroup" v-decorator="['state', { initialValue: '1' }]">
              <a-radio value="1">通过</a-radio>
              <a-radio value="2">驳回</a-radio>
            </a-radio-group>
          </a-form-item>
            <a-form-item label="说明：" prop="refuseReason" v-bind="formStyle">
              <a-textarea v-decorator="['refuseReason',{ rules: [{validator:this.verify.validateDescripte.bind(this)}],
                               getValueFromEvent: (event) => {
                                   return this.verify.formalhundredSpace(event)
                               }
                            }]"  placeholder="请输入描述"/>
            </a-form-item>
        </a-form>
        <div slot="footer">
            <a-button type="default" size="default" @click="cancelApply()">取消</a-button>
            <a-button type="primary" size="default" @click="saveApprove()">确定</a-button>
        </div>
    </a-modal>
</template>

<script>
    import verify from 'libs/verify'
    import AFormItem from 'ant-design-vue/es/form/FormItem'
    export default {
        name: 'approveAc',
        components: {
            AFormItem,
        },
        data () {
            return {
                verify,
                form: this.$form.createForm(this),
                showAddTable: false,
              refuseReason: '',
              state: '1',
              id: '',
            }
        },
        computed: {
            formStyle() {
                return this.$store.state.common.formStyle
            }
        },
        props: {
            acDTO: {
                type: Object,
                required: true
            }
        },
        watch: {
        },
        methods: {

            /**
             * Function    : showEdit
             * Description : 编辑时显示
             * Input       : opt单个所有数据
             * Return      : none
             */
            showEdit ( opt ) {
                this.showAddTable = true
                this.id = opt.recordId
            },

            /**
             * Function    : saveApply
             * Description : 角色信息新增、编辑保存
             * Input       : name
             * Return      : none
             */
            saveApprove ( ) {
                this.form.validateFields((err, value) => {
                    if (!err) {
                        let para = {}
                        para.recordId = this.id
                        para.state = value.state
                        para.refuseReason = value.refuseReason
                        this.$store.dispatch ('approveAcAct', para).then (response => {
                            this.showAddTable = false
                            if (response.code === 0) {
                                this.$emit ('init')
                                this.$message.success (response.message)
                            } else {
                                this.$message.error (response.message)
                            }
                        })
                    }
                })
            },

            /**
             * Function    : cancelApply
             * Description : 取消弹出框
             * Input       : val
             * Return      : none
             */
            cancelApply ( ) {
                this.showAddTable = false
                let _this = this
                setTimeout(function() {
                    _this.form.resetFields()
                }, 100)
            },

        },

        created () {

        }
    }
</script>
